layui.define(['layer', 'form', 'jquery','laytpl'], function (exports) {

  var $ = layui.$,
      layer = layui.layer,
      laytpl = layui.laytpl;

  var confirmInfo = {
    init: function () {
      this.initData();
    },

    initData: function () {
      var registerId = Util.getQueryString('registerId');
      $.get('/copyright/findWorksVoById', {id: registerId}, function (result) {
        if (result.success) {
          var data = result.data;

          var getTpl = $('#tpl').html(),
              $body = $(".body");
          laytpl(getTpl).render(data, function (html) {
            $body.html(html);
          });

          $('.commited-btn').click(function () {
            var registerId = Util.getQueryString('registerId');
            var index = layer.load(1, {shade: [0.1, '#fff']});
            $.get('/copyright/commitWorks',{id:registerId},function (result) {
              layer.close(index);
              if(result.success){
                // var dna = result.data[0]
                // location.href = '/copyright/register/confirmed?dna='+dna;

                location.href = '/copyright/register/confirmed?registerId='+registerId;
              }else{
                layer.msg(result.message);
              }
            });
          })

          lightbox.option({
            'resizeDuration': 200,
            'wrapAround': true
          })
        }else{
          layer.msg(result.message);
        }
      }, 'json')
    },
  }

  confirmInfo.init();
  exports('confirmInfo', {});
})